<!--
 * @Author: CoderLPF
 * @Date: 2020-04-07 14:05:04
 * @LastEditTime: 2020-05-05 18:34:17
 * @LastEditors: CoderLPF
 * @Description: 成果校审模块，运行流程同勘察纲要审核
 * @FilePath: \fzx-system-fd\src\views\modules\quality\resultsreview.vue
 -->
<template>
  <el-row :gutter="6">
    <!-- <myAnnounceDlg @operationSucc="operationState($event)" :configs="myAnnounceDlgConfig"></myAnnounceDlg> -->
    <el-col :span="24" class="col-flex">
      <el-col class="breadcrumb-container">
        <el-breadcrumb separator-class="el-icon-arrow-right">
          <el-breadcrumb-item :to="{ path: '/quality' }">质量控制</el-breadcrumb-item>
          <el-breadcrumb-item>成果校审</el-breadcrumb-item>
        </el-breadcrumb>
      </el-col>
      <!-- 主要操作区域 -->
      <el-col v-loading="config.loading" class="maincont-container">
        <div class="tab-container" v-if="config.tabShow">
          <el-tabs v-model="tabConfig.activeName">
            <el-tab-pane name="todo">
              <span slot="label">
                我的待办
                <el-badge
                  v-if="config.todoCount>0"
                  :value="config.todoCount"
                  style="margin-left:2px"
                ></el-badge>
              </span>
              <my-tableX
                v-if="tabConfig.activeName==='todo'"
                :configs="todoConfig.configs"
                :tableData="todoConfig.data"
                @dataAdd="addNewApply"
                @dataEdit="handleTodo"
              ></my-tableX>
            </el-tab-pane>
            <el-tab-pane label="运行记录" name="run">
              <my-tableX
                v-if="tabConfig.activeName==='run'"
                :configs="runingTaskConfig.configs"
                :tableData="runingTaskConfig.data"
                @dataView="viewDetail"
              ></my-tableX>
            </el-tab-pane>
            <el-tab-pane label="历史记录" name="finish">
              <my-tableX
                v-if="tabConfig.activeName==='finish'"
                :configs="completedTaskConfig.configs"
                :tableData="completedTaskConfig.data"
                @dataView="viewDetail"
              ></my-tableX>
            </el-tab-pane>
          </el-tabs>
        </div>
        <div class="flow-container" v-if="!config.tabShow">
          <div class="flow-step fix">
            <my-stepX :configs="flowConfig.stepConfig"></my-stepX>
          </div>
          <div class="flow-form scrollable">
            <el-form
              :validate-on-rule-change="false"
              :model="businessFormData"
              size="small"
              label-width="0px"
              ref="businessFormData"
              :rules="flowConfig.currentRule"
            >
              <h4 class="form-title" v-html="flowConfig.formTitle"></h4>
              <table border="1px" cellpadding="0" cellspaceing="0" class="form-data">
                <tr align="center">
                  <td class="form-label" colspan="1" width="10%">编号</td>
                  <td colspan="2" width="20%">
                    <el-input
                      size="small"
                      placeholder="自动生成"
                      :readonly="true"
                      v-model="businessFormData.proofreadId"
                    ></el-input>
                  </td>
                  <td class="form-label" colspan="3" width="30%">勘察标段/勘察单位</td>
                  <td colspan="4" width="40%">
                    <el-input size="small" :readonly="true" v-model="businessFormData.tenders"></el-input>
                  </td>
                </tr>
                <tr align="center">
                  <td class="form-label" colspan="1" width="10%">工程编号</td>
                  <td colspan="2" width="20%">
                    <el-form-item :show-message="false" prop="projectId">
                      <el-select
                        :disabled="flowConfig.stepState.step!==0"
                        placeholder="选择工程编号"
                        :readonly="true"
                        @change="changeProjectId"
                        v-model="businessFormData.projectId"
                      >
                        <el-option
                          v-for="item in dictData.prolist"
                          :key="item.projectId"
                          :label="item.projectId"
                          :value="item.projectId"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </td>
                  <td class="form-label" colspan="1" width="10%">工程名称</td>
                  <td colspan="6" width="60%">
                    <el-form-item :show-message="false" prop="projectName">
                      <el-select
                        :disabled="flowConfig.stepState.step!==0"
                        placeholder="选择工程名称"
                        :readonly="true"
                        @change="changeProjectName"
                        v-model="businessFormData.projectName"
                      >
                        <el-option
                          v-for="item in dictData.prolist"
                          :key="item.projectName"
                          :label="item.projectName"
                          :value="item.projectName"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </td>
                </tr>
                <tr align="center" style="min-height:70px">
                  <td class="form-label" width="10%">附件列表</td>
                  <td
                    :width="flowConfig.stepState.step===0?'90%':'90%'"
                    :colspan="flowConfig.stepState.step===0?9:9"
                    style="text-align:left"
                  >
                    <el-upload
                      v-if="fileList.length>0||flowConfig.stepState.step===0"
                      :disabled="flowConfig.stepState.step!==0"
                      ref="upload"
                      action="1"
                      :limit="5"
                      :accept="filetype"
                      :on-preview="handlePreview"
                      :on-remove="handleRemove"
                      :file-list="fileList"
                      :before-upload="beforeUpload"
                      :http-request="uploadSectionFile"
                    >
                      <el-button
                        v-if="flowConfig.stepState.step===0"
                        slot="trigger"
                        size="mini"
                        type="info"
                      >选取文件</el-button>
                      <div
                        v-if="flowConfig.stepState.step===0"
                        slot="tip"
                        class="el-upload__tip"
                      >上传图片、文档文件，每个不超过350M，最多上传5个，请上传完后再点击提交</div>
                    </el-upload>
                  </td>
                  <!-- <td width="10%" v-if="flowConfig.stepState.step===0">
                    <el-button size="mini" type @click="submitUpload">上传</el-button>
                  </td>-->
                </tr>
                <tr align="center">
                  <td class="form-label" width="10%" colspan="1">总体审核人</td>
                  <td width="10%" colspan="1">
                    <el-form-item :show-message="false" prop="firstApprover">
                      <el-input
                        size="small"
                        v-model="businessFormData.firstApprover"
                        :readonly="flowConfig.stepState.step!==1||flowConfig.formState.readonly"
                      ></el-input>
                    </el-form-item>
                  </td>
                  <td class="form-label" width="10%" colspan="1">联系方式</td>
                  <td width="10%" colspan="1">
                    <el-form-item :show-message="false" prop="firstContact">
                      <el-input
                        size="small"
                        v-model="businessFormData.firstContact"
                        :readonly="flowConfig.stepState.step!==1||flowConfig.formState.readonly"
                      ></el-input>
                    </el-form-item>
                  </td>
                  <td class="form-label" width="10%" colspan="1">审核时间</td>
                  <td width="10%" colspan="1">
                    <el-input size="small" v-model="businessFormData.firstTime" readonly></el-input>
                  </td>
                  <td class="form-label" width="10%" colspan="1">回复人</td>
                  <td width="10%" colspan="1">
                    <el-form-item :show-message="false" prop="firstAnswerApprover">
                      <el-input
                        size="small"
                        v-model="businessFormData.firstAnswerApprover"
                        :readonly="!(!flowConfig.stepState.isFirstTime&&flowConfig.stepState.step===0)||flowConfig.formState.readonly"
                      ></el-input>
                    </el-form-item>
                  </td>
                  <td class="form-label" width="10%" colspan="1">回复时间</td>
                  <td width="10%" colspan="1">
                    <el-input size="small" v-model="businessFormData.firstAnswerTime" readonly></el-input>
                  </td>
                </tr>
                <tr align="center">
                  <td class="form-label" width="10%" colspan="1">咨询审核人</td>
                  <td width="10%" colspan="1">
                    <el-form-item :show-message="false" prop="secondApprover">
                      <el-input
                        size="small"
                        v-model="businessFormData.secondApprover"
                        :readonly="flowConfig.stepState.step!==2||flowConfig.formState.readonly"
                      ></el-input>
                    </el-form-item>
                  </td>
                  <td class="form-label" width="10%" colspan="1">联系方式</td>
                  <td width="10%" colspan="1">
                    <el-form-item :show-message="false" prop="secondContact">
                      <el-input
                        v-model="businessFormData.secondContact"
                        size="small"
                        :readonly="flowConfig.stepState.step!==2||flowConfig.formState.readonly"
                      ></el-input>
                    </el-form-item>
                  </td>
                  <td class="form-label" width="10%" colspan="1">审核时间</td>
                  <td width="10%" colspan="1">
                    <el-input size="small" v-model="businessFormData.secondTime" readonly></el-input>
                  </td>
                  <td class="form-label" width="10%" colspan="1">回复人</td>
                  <td width="10%" colspan="1">
                    <el-form-item :show-message="false" prop="secondAnswerApprover">
                      <el-input
                        size="small"
                        v-model="businessFormData.secondAnswerApprover"
                        :readonly="!(!flowConfig.stepState.isFirstTime&&flowConfig.stepState.step===0)||flowConfig.formState.readonly"
                      ></el-input>
                    </el-form-item>
                  </td>
                  <td class="form-label" width="10%" colspan="1">回复时间</td>
                  <td width="10%" colspan="1">
                    <el-form-item>
                      <el-input v-model="businessFormData.secondAnswerTime" size="small" readonly></el-input>
                    </el-form-item>
                  </td>
                </tr>

                <tr class="form-label" align="center" style="height:36px">
                  <td colspan="6">审核意见</td>
                  <td colspan="4">意见回复</td>
                </tr>
                <tr align="center">
                  <td width="10%">勘察总体</td>
                  <td colspan="5" width="50%">
                    <el-form-item :show-message="false" prop="firstMessage">
                      <el-input
                        v-model="businessFormData.firstMessage"
                        type="textarea"
                        :rows="10"
                        :readonly="flowConfig.formState.readonly||flowConfig.stepState.step!==1"
                        placeholder="请输入审核意见"
                        resize="none"
                      ></el-input>
                    </el-form-item>
                  </td>
                  <td colspan="4" width="40%">
                    <el-form-item :show-message="false" prop="firstAnswerMessage">
                      <el-input
                        v-model="businessFormData.firstAnswerMessage"
                        :readonly="!(!flowConfig.stepState.isFirstTime&&flowConfig.stepState.step===0)||flowConfig.formState.readonly"
                        type="textarea"
                        :rows="10"
                        placeholder="请输入回复"
                        resize="none"
                      ></el-input>
                    </el-form-item>
                  </td>
                </tr>
                <tr align="center">
                  <td width="10%">咨询单位</td>
                  <td colspan="5" width="50%">
                    <el-form-item :show-message="false" prop="secondMessage">
                      <el-input
                        v-model="businessFormData.secondMessage"
                        :readonly="flowConfig.formState.readonly||flowConfig.stepState.step!==2"
                        type="textarea"
                        :rows="10"
                        placeholder="请输入审核意见"
                        resize="none"
                      ></el-input>
                    </el-form-item>
                  </td>
                  <td colspan="4" width="40%">
                    <el-form-item :show-message="false" prop="secondAnswerMessage">
                      <el-input
                        v-model="businessFormData.secondAnswerMessage"
                        :readonly="!(!flowConfig.stepState.isFirstTime&&flowConfig.stepState.step===0)||flowConfig.formState.readonly"
                        type="textarea"
                        :rows="10"
                        placeholder="请输入回复"
                        resize="none"
                      ></el-input>
                    </el-form-item>
                  </td>
                </tr>
              </table>
              <el-form-item class="btns">
                <el-button
                  v-if="!flowConfig.formState.readonly"
                  @click="resolveFlow"
                  type="primary"
                >{{flowConfig.currentBtn.resolveText}}</el-button>
                <el-button
                  v-if="!flowConfig.formState.readonly"
                  @click="rejectFlow"
                  type="info"
                >{{flowConfig.currentBtn.rejectText}}</el-button>
                <el-button @click="cancelFlow">{{flowConfig.currentBtn.cancelText}}</el-button>
              </el-form-item>
            </el-form>
            <el-collapse>
              <el-collapse-item title="处理意见区" name="comment">
                <el-timeline style="text-align:left" :reverse="true">
                  <el-timeline-item v-for="(activity, index) in flowComments" :key="index">
                    <el-card>
                      <h4>审批意见</h4>
                      <p>{{activity.time+' '+activity.group_name+'-'+activity.approver+' '+'联系方式：'+activity.contact}}</p>
                      <h5>{{activity.message}}</h5>
                      <div v-if="activity.children.length>0">
                        <h4>回复</h4>
                        <p>{{activity.children[0].time+' '+activity.children[0].group_name+'-'+activity.children[0].approver}}</p>
                        <h5>{{activity.children[0].message}}</h5>
                      </div>
                    </el-card>
                  </el-timeline-item>
                </el-timeline>
              </el-collapse-item>
            </el-collapse>
          </div>
          <myExportTableBtn :configs="exportTableConfig"></myExportTableBtn>
        </div>
      </el-col>
    </el-col>
    <!-- <div>成果校审模块正在开发中</div> -->
  </el-row>
</template>

<script>
import myTableX from "@/components/base/tableX";
import myStepX from "@/components/base/stepX";
// import myAnnounceDlg from "@/components/base/announceDlg";
import FILE_TYPE from "@/config/file.type.config";
import httpfile from "@/api/file/index";
import { formatDate } from "@/utils/date";
import { random } from "@/utils/random";
import { confirm } from "@/utils/confirm";
import myExportTableBtn from "@/components/base/exportTableBtn";

var glbVar = {}; //全局变量，从store中获取
var taskListParam = {}; // 任务列表参数，created中初始化

var refRoles = [];

export default {
  components: { myTableX, myStepX, myExportTableBtn },

  data() {
    let glbColumns = [
      { field: "proofreadId", name: "编号" },
      { field: "tenders", name: "标段" },
      { field: "projectId", name: "工程编号" },
      { field: "projectName", name: "工程名称" },
      { field: "createTime", name: "创建时间" },
    ];

    return {
      //上传完成限制
      isUploadFinished: false,
      fileListLength: 0,

      progressInfo: {},

      exportTableConfig: {
        isshown: false,
        subjectId: glbVar.subjectId,
        model: 7,
        flowFormData: this.businessFormData,
      },
      config: {
        loading: false,
        todoCount: 0,
        tabShow: true,
      },
      tabConfig: {
        activeName: "todo",
      },
      todoConfig: {
        configs: {
          columns: glbColumns,
          showFilterRow: {
            show: false,
          },
          operationBtn: {
            show: false,
            add: true,
            addtext: "添加成果校审申请",
          },
          operationCol: {
            show: true,
            edit: true,
            options: {
              edit: {
                text: "处理",
                type: "warning",
              },
            },
          },
        },
        data: [],
      },
      runingTaskConfig: {
        configs: {
          columns: glbColumns,
          showFilterRow: {
            show: false,
          },
          operationBtn: {
            show: false,
          },
          operationCol: {
            show: true,
            view: true,
            options: {
              view: {
                text: "详情",
                type: "primary",
              },
            },
          },
        },
        data: [],
      },
      completedTaskConfig: {
        configs: {
          columns: glbColumns,
          showFilterRow: {
            show: false,
          },
          operationBtn: {
            show: false,
          },
          operationCol: {
            show: true,
            view: true,
            options: {
              view: {
                text: "详情",
                type: "primary",
              },
            },
          },
        },
        data: [],
      },
      flowConfig: {
        stepConfig: {
          active: 0,
          processstatus: "process",
          data: [
            { flow_node_name: "勘察单位提交成果报告", description: "" },
            { flow_node_name: "勘察总体审核成果报告", description: "" },
            { flow_node_name: "咨询单位审核成果报告", description: "" },
          ],
        },
        stepState: {
          step: 0,
          isFirstTime: true,
        },
        currentRule: {},
        rules: {
          node_1: {
            projectId: [{ required: true }],
            projectName: [{ required: true }],
          },
          node_2: {
            firstApprover: [{ required: true }],
            firstContact: [{ required: true }],
            firstMessage: [{ required: true }],
          },
          node_3: {
            secondApprover: [{ required: true }],
            secondContact: [{ required: true }],
            secondMessage: [{ required: true }],
          },
          node_4: {
            projectId: [{ required: true }],
            projectName: [{ required: true }],
            firstAnswerApprover: [{ required: true }],
            firstAnswerMessage: [{ required: true }],
          },
          node_5: {
            projectId: [{ required: true }],
            projectName: [{ required: true }],
            firstAnswerApprover: [{ required: true }],
            firstAnswerMessage: [{ required: true }],
            secondAnswerApprover: [{ required: true }],
            secondAnswerMessage: [{ required: true }],
          },
        },
        formTitle: "北京城市副中心站<br>岩土工程勘察报告审核意见",
        formState: {
          readonly: false,
        },
        currentBtn: {
          resolveText: "发送",
          rejectText: "重置",
          cancelText: "取消",
        },
      },
      //公告
      myAnnounceDlgConfig: {
        dialogFormVisible: false,
        isupdate: false,
        announceInfo: {
          remark: "",
          subject_id: "",
          url: "",
          notice_type: "成果校审",
          role: [],
          create_by: "",
          create_time: "",
          notice_content: "",
          notice_title: "成果校审完成",
          path: "",
          remark: "",
        },
      },

      dictData: {
        prolist: [],
      },

      fileList: [],
      filetype: FILE_TYPE.resultsreview,

      businessFormData: {
        // 业务表单数据
        id: 0,
        projectId: "",
        projectName: "",
        proofreadId: "",
        subjectId: "",
        subjectName: "",
        tenders: "",
        url: "",

        firstApprover: "",
        firstContact: "",
        firstTime: "",
        firstAnswerApprover: "",
        firstAnswerTime: "",
        secondApprover: "",
        secondContact: "",
        secondTime: "",
        secondAnswerApprover: "",
        secondAnswerTime: "",
        firstMessage: "",
        firstAnswerMessage: "",
        secondMessage: "",
        secondAnswerMessage: "",
      },

      flowFormData: {
        // 流程表单数据
        // 发起
        start: {
          businessid: null,
          businesstype: "7",
          major: null,
          userid: null,
          path: "",
        },

        // 审核
        check: {
          first: {
            approver: "",
            contact: "",
            time: "",
            message: "",
            parent: 0,
          },
          second: {
            approver: "",
            contact: "",
            time: "",
            message: "",
            parent: 0,
          },
        },

        // 回复
        answer: {
          first: {
            approver: "",
            contact: "",
            time: "",
            message: "",
            parent: 0,
          },
          second: {
            approver: "",
            contact: "",
            time: "",
            message: "",
            parent: 0,
          },
        },
      },

      flowParam: {},

      flowComments: [],
    };
  },

  /**
   * @description: 生命周期钩子，创建组件
   * @param {type}
   * @return:
   */
  created() {
    glbVar.subjectId = this.$store.state.projectInfo.projectName;
    glbVar.user = this.$store.state.m_user.userInfo;

    this.todoConfig.configs.operationBtn.show = glbVar.user.user_type === "1";

    // 初始化查询列表参数
    taskListParam.projectId = glbVar.subjectId; //项目名称
    taskListParam.businessType = 7; // 业务类型
    taskListParam.userId = glbVar.user.id; //用户id

    this.flowFormData.start.userid = glbVar.user.id;
    this.flowFormData.start.path = this.$route.path;

    let query = this.$route.query;

    if (query.id && query.todo) {
      this.$api.resultsreview.getbyid(query.id).then((res) => {
        if (res.code === 200) {
          this.handleTodo(res.data);
        }
      });
    } else if (query.id && !query.todo) {
      this.$api.resultsreview.getbyid(query.remark).then((res) => {
        if (res.code === 200) {
          this.viewDetail(res.data);
        }
      });
    }
  },

  /**
   * @description: 生命周期钩子，加载组件节点完成
   * @param {type}
   * @return:
   */
  mounted() {
    if (glbVar.user.user_type === "1") {
      this.$api.project
        .listByCompany(glbVar.subjectId, glbVar.user.company)
        .then((res) => {
          if (res.code === 200) {
            this.dictData.prolist = res.data;
          }
        });
    }
    this.initList();

    //文件导出 是否可见
    this.exportTableConfig.isshown =
      this.flowConfig.formState.readonly && this.flowConfig.stepState.step == 3;
    this.exportTableConfig.subjectId = glbVar.subjectId;
  },

  /**
   * @description: 监听器
   * @param {type}
   * @return:
   */
  watch: {
    /**
     * @description: 路由监听器，路由发生变化时，刷新当前列表
     * @param {type}
     * @return:
     */
    $route(to, from) {
      this.initList();
    },
    //文件导出 是否可见 监听变化
    businessFormData(newstate, old) {
      this.exportTableConfig.flowFormData = newstate;
    },
    "flowConfig.formState.readonly"(newstate, old) {
      this.exportTableConfig.isshown =
        this.flowConfig.formState.readonly &&
        this.flowConfig.stepState.step == 3;
    },
    "flowConfig.stepState.step"(newstate, old) {
      if (newstate == 3) {
        this.exportTableConfig.isshown =
          this.flowConfig.formState.readonly &&
          this.flowConfig.stepState.step == 3;
      }
    },
  },

  methods: {
    /**
     * @description: 初始化待办，运行记录，历史记录列表，刷新
     * @param {type}
     * @return:
     */
    initList() {
      this.config.loading = true;
      this.$api.startitem
        .getmytasklist(taskListParam)
        .then((res) => {
          if (res.code === 200) {
            if (res.data && res.data.length > 0) {
              this.$api.resultsreview
                .getbyids({ ids: res.data })
                .then((res) => {
                  if (res.code === 200) {
                    this.config.loading = false;
                    this.todoConfig.data = res.data;
                  } else {
                    this.config.loading = false;
                  }
                })
                .catch((err) => {
                  this.config.loading = false;
                  console.log(err);
                });
            } else {
              this.config.loading = false;
              this.todoConfig.data = [];
              // this.$message.info("暂无待办任务");
            }
          } else {
            this.config.loading = false;
          }
        })
        .catch((err) => {
          this.config.loading = false;
          console.log(err);
        });

      this.$api.startitem
        .getprocessinglist(taskListParam)
        .then((res) => {
          if (res.code === 200) {
            if (res.data && res.data.length > 0) {
              this.$api.resultsreview
                .getbyids({ ids: res.data })
                .then((res) => {
                  if (res.code === 200) {
                    this.runingTaskConfig.data = res.data;
                  }
                })
                .catch((err) => {
                  console.log(err);
                });
            } else {
              this.runingTaskConfig.data = [];
              // this.$message.info("暂无运行记录");
            }
          }
        })
        .catch((err) => {
          console.log(err);
        });

      this.$api.startitem
        .getfinishedlist(taskListParam)
        .then((res) => {
          if (res.code === 200) {
            if (res.data && res.data.length > 0) {
              this.$api.resultsreview
                .getbyids({ ids: res.data })
                .then((res) => {
                  if (res.code === 200) {
                    this.completedTaskConfig.data = res.data;
                  }
                })
                .catch((err) => {
                  console.log(err);
                });
            } else {
              this.completedTaskConfig.data = [];
              // this.$message.info("暂无历史记录");
            }
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },

    //监听上传公告结果
    operationState(msg) {
      console.log(msg);
      if (msg) {
        this.$message.success("发布成功");
      } else {
        this.$message.error("发布失败");
      }
      this.refreshCurrent();
    },
    /**
     * @description: 刷线当前页面
     * @param {type}
     * @return:
     */
    refreshCurrent() {
      this.config.tabShow = true;
      if (this.$route.query) {
        this.$router.replace({ path: this.$route.path, query: {} });
        this.initList();
      } else {
        this.initList();
      }
    },

    /** tab操作区 */
    /**
     * @description: 新增一个成果校审申请
     * @param {type}
     * @return:
     */
    addNewApply() {
      this.initFormData_Add(); //初始化业务表单数据
      this.flowConfig.stepConfig.active = 0; //设置步骤条当前节点
      this.flowConfig.formState.readonly = false; //设置表单是否只读
      this.config.tabShow = false; //切换列表和表单
      this.flowConfig.stepState.isFirstTime = true; // 配置是否第一次申请
      this.flowConfig.stepState.step = 0;
      this.flowConfig.currentBtn = {
        resolveText: "发送",
        rejectText: "重置",
        cancelText: "取消",
      };
      this.flowConfig.currentRule = this.flowConfig.rules.node_1;
    },

    /**
     * @description:
     * @param {type}
     * @return:
     */
    handleTodo(row) {
      this.$api.nodeprogress
        .query({
          subject_id: row.subjectId,
          project_id: row.projectId,
        })
        .then((res) => {
          if (res.code === 200) {
            if (res.data && res.data.length > 0) {
              this.progressInfo = {
                id: res.data[0].id,
              };
            }
          }
        });
      this.initFormData_Handle(row);
    },

    /**
     * @description: 查看详情
     * @param {type}
     * @return:
     */
    viewDetail(row) {
      this.initFormData_View(row);
      // this.flowConfig.stepConfig.active = 0; //设置步骤条当前节点
      // this.flowConfig.formState.readonly = false; //设置表单是否只读
      this.config.tabShow = false; //切换列表和表单
      // this.flowConfig.stepState.isFirstTime = true; // 配置是否第一次申请
      // this.flowConfig.stepState.step = 0;
    },

    /**
     * @description: 初始化表单参数，用于新增业务和流程
     * @param {type}
     * @return:
     */
    initFormData_Add() {
      let tempformData = {};
      tempformData.subjectId = glbVar.subjectId;
      tempformData.subjectName = glbVar.subjectId;
      tempformData.tenders = glbVar.user.nick_name + "/" + glbVar.user.company;
      tempformData.projectName = "";
      tempformData.projectId = "";
      tempformData.createTime = formatDate(new Date(), "yyyy-MM-dd hh:mm:ss");
      this.businessFormData = tempformData;

      this.fileList = [];

      // 初始化流程表单
      this.flowFormData.check = {
        first: {
          approver: "",
          contact: "",
          time: "",
          message: "",
          parent: 0,
        },
        second: {
          approver: "",
          contact: "",
          time: "",
          message: "",
          parent: 0,
        },
      };
      this.flowFormData.answer = {
        first: {
          approver: "",
          contact: "",
          time: "",
          message: "",
          parent: 0,
        },
        second: {
          approver: "",
          contact: "",
          time: "",
          message: "",
          parent: 0,
        },
      };
    },

    /**
     * @description: 初始化表单参数，用于处理业务和流程
     * @param {type}
     * @return:
     */
    initFormData_Handle(row) {
      let tempformData = {
        id: 0,
        projectId: "",
        projectName: "",
        proofreadId: "",
        subjectId: "",
        subjectName: "",
        tenders: "",
        url: "",

        firstApprover: "",
        firstContact: "",
        firstTime: "",
        firstAnswerApprover: "",
        firstAnswerTime: "",
        secondApprover: "",
        secondContact: "",
        secondTime: "",
        secondAnswerApprover: "",
        secondAnswerTime: "",
        firstMessage: "",
        firstAnswerMessage: "",
        secondMessage: "",
        secondAnswerMessage: "",
      };
      tempformData.subjectId = row.subjectId;
      tempformData.subjectName = row.subjectName;
      tempformData.tenders = row.tenders;
      tempformData.projectName = row.projectName;
      tempformData.projectId = row.projectId;
      tempformData.createTime = row.createTime;
      tempformData.proofreadId = row.proofreadId;
      tempformData.id = row.id;

      this.businessFormData = tempformData;

      this.fileList = [];
      // ##修改##
      if (row.url != "") {
        row.url.split(";").forEach((item) => {
          if (item != "") {
            let b = item.split("/");
            this.fileList.push({
              name: b[b.length - 1].slice(18),
              realname: b.slice(b.length - 1, b.length).toString(String),
              url: item,
            });
          }
        });
      }
      // ##修改##

      // 获取审批意见
      let param = {
        businesstype: 7,
        businessid: row.id,
      };

      // 初始化公告默认角色列表
      this.$api.startitem.getRoleByRuningInfo(7, row.id).then((res) => {
        if (res.code === 200) {
          refRoles = res.data;
        }
      });

      this.$api.startitem
        .isfirsttime(param)
        .then((res) => {
          if (res.code === 200) {
            this.flowConfig.stepState.isFirstTime = res.data;
            this.$api.startitem
              .getworkflow({
                businessType: 7,
                businessId: row.id,
              })
              .then((res) => {
                if (res.code === 200) {
                  let { id, proc_inst_id } = res.data;
                  this.$api.startitem
                    .getcurrentstage({
                      executionId: id,
                      procInstId: proc_inst_id,
                    })
                    .then((res) => {
                      if (res.code === 200) {
                        this.flowConfig.stepConfig.active = res.data[0]; //设置步骤条当前节点
                        this.flowConfig.formState.readonly = false; //设置表单是否只读
                        this.changeStep(res.data[0]);
                        this.initComments(row.id, true, res.data[0]);

                        // 初始化流程提交参数
                        this.flowParam = {
                          executionId: id,
                          flowNodeId: res.data[1],
                          message: "",
                          procInstId: proc_inst_id,
                          userId: glbVar.user.id,
                          time: "",
                          contact: "",
                          parent: 0,
                          approver: "",
                        };

                        this.config.tabShow = false; //切换列表和表单
                      }
                    })
                    .catch((err) => {
                      console.log(err);
                    });
                }
              })
              .catch((err) => {
                console.log(err);
              });
          }
        })
        .catch((err) => {
          console.log("isfirsttime res err:" + err);
        });
    },

    initComments(id, todo, step) {
      this.flowComments = [];
      this.$api.startitem
        .getcomment({
          businessType: 7,
          businessId: id,
        })
        .then((res) => {
          if (res.code === 200) {
            this.flowComments = res.data;
            let firstCheck = this.flowComments.filter((item) => {
              return item.group_name === "勘察总体";
            });
            let secondCheck = this.flowComments.filter((item) => {
              return item.group_name === "咨询单位";
            });
            if (todo) {
              this.handleCommentShow(firstCheck, secondCheck);
            } else {
              this.handleCommentShowHI(firstCheck, secondCheck);
            }
          }
        });
    },

    /**
     * @description: 处理表单区域审核意见的显示模式
     * @param {type}
     * @return:
     */
    handleCommentShow(firstCheck, secondCheck) {
      // if (this.flowConfig.stepState.isFirstTime) {
      if (firstCheck.length > 0) {
        this.flowFormData.check.first = firstCheck[firstCheck.length - 1];
        this.businessFormData.firstApprover =
          firstCheck[firstCheck.length - 1].approver;
        this.businessFormData.firstContact =
          firstCheck[firstCheck.length - 1].contact;
        this.businessFormData.firstTime =
          firstCheck[firstCheck.length - 1].time;
        this.businessFormData.firstMessage =
          firstCheck[firstCheck.length - 1].message;

        let abc = firstCheck[0];
        if (abc.children.length > 0) {
          this.businessFormData.firstAnswerMessage = abc.children[0].message;
          this.businessFormData.firstAnswerApprover = abc.children[0].approver;
          this.businessFormData.firstAnswerTime = abc.children[0].time;
        }

        if (this.flowConfig.stepState.step === 0) {
          this.flowConfig.currentRule = this.flowConfig.rules["node_4"];
        }
      }
      if (secondCheck.length > 0) {
        this.flowFormData.check.second = secondCheck[secondCheck.length - 1];
        this.businessFormData.secondApprover =
          secondCheck[secondCheck.length - 1].approver;
        this.businessFormData.secondContact =
          secondCheck[secondCheck.length - 1].contact;
        this.businessFormData.secondTime =
          secondCheck[secondCheck.length - 1].time;
        this.businessFormData.secondMessage =
          secondCheck[secondCheck.length - 1].message;

        let bcd = secondCheck[0];
        if (bcd.children.length > 0) {
          this.businessFormData.secondAnswerMessage = bcd.children[0].message;
          this.businessFormData.secondAnswerApprover = bcd.children[0].approver;
          this.businessFormData.secondAnswerTime = bcd.children[0].time;
        }

        if (this.flowConfig.stepState.step === 0) {
          this.flowConfig.currentRule = this.flowConfig.rules["node_5"];
        }
      }
    },

    handleCommentShowHI(firstCheck, secondCheck) {
      if (firstCheck.length > 0) {
        this.flowFormData.check.first = firstCheck[firstCheck.length - 1];
        this.businessFormData.firstApprover =
          firstCheck[firstCheck.length - 1].approver;
        this.businessFormData.firstContact =
          firstCheck[firstCheck.length - 1].contact;
        this.businessFormData.firstTime =
          firstCheck[firstCheck.length - 1].time;
        this.businessFormData.firstMessage =
          firstCheck[firstCheck.length - 1].message;

        let abc = firstCheck[0];
        if (abc.children.length > 0) {
          this.businessFormData.firstAnswerMessage = abc.children[0].message;
          this.businessFormData.firstAnswerApprover = abc.children[0].approver;
          this.businessFormData.firstAnswerTime = abc.children[0].time;
        }
      }
      if (secondCheck.length > 0) {
        console.log(secondCheck);

        this.flowFormData.check.second = secondCheck[secondCheck.length - 1];
        this.businessFormData.secondApprover =
          secondCheck[secondCheck.length - 1].approver;
        this.businessFormData.secondContact =
          secondCheck[secondCheck.length - 1].contact;
        this.businessFormData.secondTime =
          secondCheck[secondCheck.length - 1].time;
        this.businessFormData.secondMessage =
          secondCheck[secondCheck.length - 1].message;

        let bcd = secondCheck[0];
        if (bcd.children.length > 0) {
          this.businessFormData.secondAnswerMessage = bcd.children[0].message;
          this.businessFormData.secondAnswerApprover = bcd.children[0].approver;
          this.businessFormData.secondAnswerTime = bcd.children[0].time;
        }
      }
    },

    changeStep(step) {
      this.flowConfig.stepState.step = step;
      this.flowConfig.currentRule = this.flowConfig.rules["node_" + (step + 1)];
      console.log(this.flowConfig.currentRule);

      if (
        this.flowConfig.stepState.step === 0 &&
        !this.flowConfig.stepState.isFirstTime
      ) {
        // 重新发起
        this.flowConfig.currentBtn = {
          resolveText: "重新发送",
          rejectText: "重置",
          cancelText: "取消",
        };
      } else {
        this.flowConfig.currentBtn = {
          resolveText: "通过",
          rejectText: "驳回",
          cancelText: "取消",
        };
      }
    },

    /**
     * @description: 初始化表单参数，用于查看业务和流程
     * @param {type}
     * @return:
     */
    initFormData_View(row) {
      let tempformData = {};
      tempformData.subjectId = row.subjectId;
      tempformData.subjectName = row.subjectName;
      tempformData.tenders = row.tenders;
      tempformData.createTime = row.createTime;
      tempformData.projectName = row.projectName;
      tempformData.projectId = row.projectId;
      tempformData.createTime = row.createTime;
      tempformData.proofreadId = row.proofreadId;

      this.businessFormData = tempformData;
      this.fileList = [];
      // ##修改##
      if (row.url != "") {
        row.url.split(";").forEach((item) => {
          if (item != "") {
            let b = item.split("/");
            this.fileList.push({
              name: b[b.length - 1].slice(18),
              realname: b.slice(b.length - 1, b.length).toString(String),
              url: item,
            });
          }
        });
      }
      // ##修改##

      let param = {
        businesstype: 7,
        businessid: row.id,
      };
      this.$api.startitem
        .isfirsttime(param)
        .then((res) => {
          if (res.code === 200) {
            this.flowConfig.stepState.isFirstTime = res.data;
            this.$api.startitem
              .getworkflow({
                businessType: 7,
                businessId: row.id,
              })
              .then((res) => {
                if (res.code === 200) {
                  let { id, proc_inst_id } = res.data;
                  this.$api.startitem
                    .getcurrentstage({
                      executionId: id,
                      procInstId: proc_inst_id,
                    })
                    .then((res) => {
                      if (res.code === 200) {
                        this.flowConfig.stepConfig.active = res.data[0]; //设置步骤条当前节点
                        this.flowConfig.formState.readonly = true; //设置表单是否只读
                        this.changeStep(res.data[0]);
                        this.initComments(row.id, false, res.data[0]);

                        this.config.tabShow = false; //切换列表和表单
                      }
                    })
                    .catch((err) => {
                      console.log(err);
                    });
                }
              })
              .catch((err) => {
                console.log(err);
              });
          }
        })
        .catch((err) => {
          console.log("isfirsttime res err:" + err);
        });
    },

    /** 流程表单操作区域 */

    /**
     * @description:
     * @param {type}
     * @return:
     */
    changeProjectId(value) {
      this.dictData.prolist.forEach((item) => {
        console.log("item" + item);

        if (item.projectId === value) {
          this.businessFormData.projectName = item.projectName;
          this.flowFormData.start.major = item.major;
          return;
        }
      });
    },

    /**
     * @description:
     * @param {type}
     * @return:
     */
    changeProjectName(value) {
      this.dictData.prolist.forEach((item) => {
        console.log("item" + item);

        if (item.projectName === value) {
          this.businessFormData.projectId = item.projectId;
          this.flowFormData.start.major = item.major;
          return;
        }
      });
    },

    /**
     * @description: 执行流程，发起，审批通过
     * @param {type}
     * @return:
     */
    resolveFlow() {
      this.businessFormData.url = this.fileList
        .map((item) => {
          return "/" + glbVar.subjectId + "/成果校审/" + item.realname;
        })
        .join(";");

      if (!confirm(this.businessFormData.url, this.isUploadFinished)) {
        console.log("return");

        return;
      }

      this.$refs.businessFormData.validate((res) => {
        if (res) {
          this.$confirm("提交后不可更改，是否继续？", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
            .then(() => {
              if (
                this.flowConfig.stepState.step === 0 &&
                this.flowConfig.stepState.isFirstTime
              ) {
                // 如果是第一次申请，新增表单，发起流程
                this.addNewBusinessAndStartFlow();
              } else if (
                this.flowConfig.stepState.step === 0 &&
                !this.flowConfig.stepState.isFirstTime
              ) {
                // 重新发起流程
                this.updateBusinessAndAnswerCheck();
              } else if (this.flowConfig.stepState.step === 1) {
                this.addFirstFlowCheck();
                // 勘察总体撰写意见
              } else if (this.flowConfig.stepState.step === 2) {
                // 咨询总体编写意见
                this.addSecondFlowCheck();
              }
            })
            .catch(() => {
              return;
            });
        } else {
          this.$message.warning("请检查必填项");
        }
      });
    },

    /**
     * @description: 重置，驳回流程
     * @param {type}
     * @return:
     */
    rejectFlow() {
      if (this.flowConfig.stepState.step === 0) {
        // 重置
        this.businessFormData.firstAnswerApprover = "";
        this.businessFormData.secondAnswerApprover = "";
        this.businessFormData.firstAnswerMessage = "";
        this.businessFormData.secondAnswerMessage = "";
        return;
      }
      this.$refs.businessFormData.validate((res) => {
        if (res) {
          this.$confirm("提交后不可更改，是否继续？", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
            .then(() => {
              if (this.flowConfig.stepState.step === 1) {
                this.firstReject();
                // 勘察总体撰写意见
              } else if (this.flowConfig.stepState.step === 2) {
                // 咨询总体编写意见
                this.secondReject();
              }
            })
            .catch(() => {
              return;
            });
        } else {
          this.$message.warning("请检查必填项");
        }
      });
    },

    /**
     * @description: 返回，取消
     * @param {type}
     * @return:
     */
    cancelFlow() {
      this.config.tabShow = true;
      this.businessFormData = {
        id: 0,
        projectId: "",
        projectName: "",
        proofreadId: "",
        subjectId: "",
        subjectName: "",
        tenders: "",
        url: "",
      };
      this.flowFormData = {
        start: {
          businessid: null,
          businesstype: "7",
          major: null,
          userid: null,
          path: "",
        },

        // 审核
        check: {
          first: {
            approver: "",
            contact: "",
            time: "",
            message: "",
            parent: 0,
          },
          second: {
            approver: "",
            contact: "",
            time: "",
            message: "",
            parent: 0,
          },
        },

        // 回复
        answer: {
          first: {
            approver: "",
            contact: "",
            time: "",
            message: "",
            parent: 0,
          },
          second: {
            approver: "",
            contact: "",
            time: "",
            message: "",
            parent: 0,
          },
        },
      };
      this.initList();
    },

    /** 具体表单操作区，执行业务和流程 */
    /**
     * @description: 新增业务数据，执行发起流程
     * @param {type}
     * @return:
     */
    addNewBusinessAndStartFlow() {
      this.config.loading = true;

      this.$api.resultsreview
        .add(this.businessFormData)
        .then((res) => {
          if (res.code === 200) {
            this.flowFormData.start.businessid = res.data.id;
            this.$api.startitem
              .starttask(this.flowFormData.start)
              .then((res) => {
                this.config.loading = false;
                if (res.code === 200) {
                  this.$message.success("发送成功，成果已提交勘察总体审批");
                  this.finishInsideWork({
                    subject_id: glbVar.subjectId,
                    project_id: this.businessFormData.projectId,
                  });
                  this.refreshCurrent();
                }
              })
              .catch((err) => {
                this.config.loading = false;
                this.$message.error("发送失败：" + err);
                console.log("submit resultsreview flow err" + err);
              });
          } else {
            this.config.loading = false;
          }
        })
        .catch((err) => {
          this.config.loading = true;
          this.$message.error("发送失败：" + err);
          console.log("add new business err" + err);
        });
    },

    finishInsideWork(ob) {
      this.$api.nodeprogress.query(ob).then((res) => {
        if (res.code === 200) {
          if (res.data && res.data.length > 0) {
            this.$api.nodeprogress
              .update({
                id: res.data[0].id,
                inside_work: formatDate(new Date(), "yyyy-MM-dd hh:mm:ss"),
              })
              .then((res) => {
                if (res.code === 200) {
                  console.log("内业完成时间更新成功");
                }
              })
              .catch((err) => {
                console.log("内业完成时间更新成功");
                console.log(err);
              });
          }
        }
      });
    },

    /**
     * @description: 修改表单，重新发送，回复意见
     * @param {type}
     * @return:
     */
    updateBusinessAndAnswerCheck() {
      this.config.loading = true;

      this.$api.resultsreview
        .update(this.businessFormData)
        .then((res) => {
          if (res.code === 200) {
            this.$message.success("修改业务表单成功");
            let dd = formatDate(new Date(), "yyyy-MM-dd hh:mm:ss");
            let answer1 = {
              executionId: this.flowParam.executionId,
              flowNodeId: this.flowParam.flowNodeId,
              message: this.businessFormData.firstAnswerMessage,
              procInstId: this.flowParam.procInstId,
              userId: this.flowParam.userId,
              time: dd,
              contact: "",
              parent: this.flowFormData.check.first.id,
              approver: this.businessFormData.firstAnswerApprover,
            };
            let answer2 = {
              executionId: this.flowParam.executionId,
              flowNodeId: this.flowParam.flowNodeId,
              message: this.businessFormData.secondAnswerMessage,
              procInstId: this.flowParam.procInstId,
              userId: this.flowParam.userId,
              time: dd,
              contact: "",
              parent: this.flowFormData.check.second.id,
              approver: this.businessFormData.secondAnswerApprover,
            };
            let param = [];
            param.push(answer1);
            if (this.flowFormData.check.second.message !== "") {
              param.push(answer2);
            }

            this.$api.startitem
              .approve(param)
              .then((res) => {
                this.config.loading = false;
                if (res.code === 200) {
                  this.$message.success("提交成功");
                  this.refreshCurrent();
                }
              })
              .catch((err) => {
                this.config.loading = false;
                this.$message.error("提交失败：" + err);
              });
          } else {
            this.config.loading = false;
          }
        })
        .catch((err) => {
          this.config.loading = false;
          console.log(err);
        });
    },

    addFirstFlowCheck() {
      this.flowParam.message = this.businessFormData.firstMessage;
      this.flowParam.approver = this.businessFormData.firstApprover;
      this.flowParam.contact = this.businessFormData.firstContact;
      this.flowParam.time = formatDate(new Date(), "yyyy-MM-dd hh:mm:ss");

      console.log("flowParam");
      console.log(this.flowParam);
      this.config.loading = true;
      this.$api.startitem
        .approve([this.flowParam])
        .then((res) => {
          this.config.loading = false;
          if (res.code === 200) {
            this.$message.success("操作成功");

            this.progressInfo.prospecting_verification = this.flowParam.time;
            this.$api.nodeprogress.update(this.progressInfo).then((res) => {
              if (res.code === 200) {
                this.$message.success("总体审核结束，时间更新");
              }
            });

            // // this.refreshCurrent();
            // if (this.flowConfig.stepState.step === 2) {
            //   //添加公告
            //   this.myAnnounceDlgConfig.isupdate = false;
            //   this.myAnnounceDlgConfig.announceInfo.create_by = "";
            //   this.myAnnounceDlgConfig.announceInfo.remark = this.flowFormData.id;
            //   this.myAnnounceDlgConfig.announceInfo.subject_id =
            //     glbVar.subjectId;
            //   this.myAnnounceDlgConfig.announceInfo.notice_content =
            //     "成果校审内容";
            //   this.myAnnounceDlgConfig.dialogFormVisible = true;
            // } else {
            //   this.refreshCurrent();
            // }
            this.refreshCurrent();
          }
        })
        .catch((err) => {
          this.config.loading = false;
          console.log(err);
        });
    },

    addSecondFlowCheck() {
      this.flowParam.message = this.businessFormData.secondMessage;
      this.flowParam.approver = this.businessFormData.secondApprover;
      this.flowParam.contact = this.businessFormData.secondContact;
      this.flowParam.time = formatDate(new Date(), "yyyy-MM-dd hh:mm:ss");

      this.config.loading = true;
      this.$api.startitem
        .approve([this.flowParam])
        .then((res) => {
          if (res.code === 200) {
            this.config.loading = false;
            this.$message.success("操作成功");
            this.progressInfo.consultation_verification = this.flowParam.time;
            this.$api.nodeprogress.update(this.progressInfo).then((res) => {
              if (res.code === 200) {
                this.$message.success("成果提交结束，时间更新");
              }
            });
            if (this.flowConfig.stepState.step === 2) {
              //添加公告
              // this.myAnnounceDlgConfig.isupdate = false;
              // this.myAnnounceDlgConfig.announceInfo.create_by =
              //   "咨询单位-" + this.flowParam.approver;
              // this.myAnnounceDlgConfig.announceInfo.remark = this.businessFormData.id;
              // this.myAnnounceDlgConfig.announceInfo.subject_id =
              //   glbVar.subjectId;
              // this.myAnnounceDlgConfig.announceInfo.notice_content = "成果校审";
              // this.myAnnounceDlgConfig.dialogFormVisible = true;
              // this.myAnnounceDlgConfig.announceInfo.notice_title =
              //   "【" +
              //   this.businessFormData.tenders.split("/")[0] +
              // 	"】成果校审完成";

              let announce = {
                subject_id: glbVar.subjectId,
                url: "",
                remark: this.businessFormData.id,
                notice_type: "成果校审",
                role: refRoles,
                create_by: this.flowParam.approver,
                create_time: this.flowParam.time,
                notice_content:
                  "【" +
                  this.businessFormData.tenders.split("/")[0] +
                  "】成果校审完成",
                notice_title:
                  "【" +
                  this.businessFormData.tenders.split("/")[0] +
                  "】成果校审完成",
                path: this.$route.path,
              };

              this.$api.announce
                .add(announce)
                .then((res) => {
                  this.config.loading = false;
                  if (res.code == 200) {
                    this.$message.success("操作成功!");
                    this.refreshCurrent();
                  } else {
                    this.$message.error("操作失败!" + res.msg);
                  }
                })
                .catch((err) => {
                  this.config.loading = false;
                  this.$message.error("操作失败!" + err);
                });
            } else {
              this.refreshCurrent();
            }
          }
        })
        .catch((err) => {
          this.config.loading = false;
          console.log(err);
        });
    },

    firstReject() {
      this.flowParam.message = this.businessFormData.firstMessage;
      this.flowParam.approver = this.businessFormData.firstApprover;
      this.flowParam.contact = this.businessFormData.firstContact;
      this.flowParam.time = formatDate(new Date(), "yyyy-MM-dd hh:mm:ss");

      this.config.loading = true;
      this.$api.startitem
        .disapprove(this.flowParam)
        .then((res) => {
          this.config.loading = false;
          if (res.code === 200) {
            this.$message.success("操作成功");
            this.refreshCurrent();
          }
        })
        .catch((err) => {
          this.config.loading = false;
          this.$message.error("操作失败：" + err);
          console.log(err);
        });
    },

    secondReject() {
      this.flowParam.message = this.businessFormData.secondMessage;
      this.flowParam.approver = this.businessFormData.secondApprover;
      this.flowParam.contact = this.businessFormData.secondContact;
      this.flowParam.time = formatDate(new Date(), "yyyy-MM-dd hh:mm:ss");

      this.config.loading = true;
      this.$api.startitem
        .disapprove(this.flowParam)
        .then((res) => {
          this.config.loading = false;
          if (res.code === 200) {
            this.$message.success("操作成功");
            this.refreshCurrent();
          }
        })
        .catch((err) => {
          this.config.loading = false;
          this.$message.error("操作失败：" + err);
          console.log(err);
        });
    },

    /**
     * @description: 更新业务数据
     * @param {type}
     * @return:
     */
    updateBusiness() {},

    /** 文件附件操作区 */

    /**
     * @description: 点击预览文件，下载
     * @param {type}
     * @return:
     */
    handlePreview(file) {
      window.open(file.url);
    },

    /**
     * @description: 处理删除
     * @param {type}
     * @return:
     */
    handleRemove(file, fileList) {
      let temp = this.fileList.filter((item) => {
        return item.uid !== file.uid;
      });
      this.fileList = temp;
      this.fileListLength -= 1;
    },

    submitUpload() {
      this.$refs.upload.submit();
    },

    /**
     * @description: 处理上传
     * @param {type}
     * @return:
     */
    beforeUpload(file) {
      let testmsg = file.name.substring(file.name.lastIndexOf(".") + 1);
      if (this.filetype.indexOf("." + testmsg.toLowerCase()) < 0) {
        this.$message({
          message: "上传文件格式不符合要求：" + testmsg,
          type: "warning",
        });
        return false;
      }
      return true;
    },

    /**
     * @description: 上传
     * @param {type}
     * @return:
     */
    uploadSectionFile(params) {
      this.isUploadFinished = false;
      this.fileListLength += 1;

      const uid = params.file.uid;
      // ##修改##
      let URL = window.URL || window.webkitURL;
      let url = URL.createObjectURL(params.file);

      let keyname = formatDate(new Date(), "yyyyMMddhhmmss") + random();
      // ##修改##

      const fileData = new FormData();
      fileData.append("file", params.file);
      const query = {
        path:
          "/" +
          this.$store.state.projectInfo.projectName +
          "/成果校审/" +
          keyname +
          params.file.name,
      };

      const config = {
        headers: {
          "Content-Type": "multipart/form-data",
          token: window.sessionStorage.getItem("token"),
        },
        // 这一段代码解决进度条不显示的问题，属于 axios 的使用知识。具体可以看文末的参考链接。
        onUploadProgress: (progressEvent) => {
          const percentCompleted = Math.floor(
            (progressEvent.loaded * 100) / progressEvent.total
          );
          params.onProgress({ percent: percentCompleted });
        },
      };

      httpfile.upload(query, config, fileData).then((res) => {
        if (res.status == 200) {
          // ##修改##
          this.fileList.push({
            url: url,
            name: params.file.name,
            realname: keyname + params.file.name,
          });
          // ##修改##
          params.onSuccess(res);

          if (this.fileListLength === this.fileList.length) {
            console.log("炒鸡成功");
            this.isUploadFinished = true;
          } else {
            console.log("普通成功");
            this.isUploadFinished = false;
          }
        }
      });
    },
  },
};
</script>
<style lang='less' scoped>
.col-flex {
  box-sizing: border-box;
  padding-top: 30px;
  height: 100%;
  .breadcrumb-container {
    height: 30px;
    margin-top: -20px;
  }
  .maincont-container {
    height: calc(~"100% - 10px");
    margin-top: 3px;
    .tab-container {
      height: 100%;
      /deep/.el-tabs {
        height: 100%;

        .el-tabs__header {
          margin: 0;
        }
        .el-tabs__content {
          height: calc(~"100% - 40px");
          .el-tab-pane {
            height: 100%;
          }
        }
      }
    }
    .flow-container {
      height: 100%;
      width: 100%;
      box-sizing: border-box;
      padding-top: 60px;

      .flow-step {
        width: 100%;
        height: 60px;
        margin-top: -60px;
      }

      .flow-form {
        text-align: center;
        height: calc(~"100% - 10px");
        // margin-bottom: 10px;

        table .form-label {
          background-color: #efefef;
          margin-bottom: 10px;
        }

        .form-title {
          margin: 10px !important;
        }

        .form-data {
          border-collapse: collapse;
          margin: auto;
          width: 85%;
          font-size: 13px;

          /deep/.el-input {
            height: normal;
            .el-input__inner {
              padding: 0px 5px !important;
            }
          }

          .el-form-item {
            padding: 0px;
            margin: 0px;
            .el-form-item__content {
              line-height: normal;
            }
            .el-select {
              display: block !important;
            }
          }
        }
        .btns {
          width: 85%;
          margin: 20px auto;
          display: flex;
          justify-content: flex-end;
        }
      }

      .scrollable {
        overflow: auto;
      }
    }
  }
  /deep/.addbutton-con {
    button {
      box-shadow: 0px 0px 0px 3px #66b1ff55;
    }
    i {
      font-size: 20px;
    }
    z-index: 100;
    position: absolute;
    top: 10px;
    right: 10px;
    margin: 5px;
    height: 40px;
    border-radius: 50%;
    // box-shadow: 0px 0px 0px 2px gray;
  }
}
</style>